<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Settings extends CI_Controller {

    	public function __construct()
	{
		parent::__construct();
                
		$this->load->library('lib_help');
		$this->load->Model('Users_model', '', TRUE);
                $this->load->Model('Tasks_model', '', TRUE);
	}
    
	public function index()
	{
            $data = '';
            
            //проверка авторизации
            if($this->lib_help->check_auth() || $this->Users_model->checkSocUserAuth())
                $this->data['user'] = $this->Users_model->getUser($_SESSION['user_id']);
            else
                die("Чтобы попасть в кабинет, необходимо авторизоваться в системе");
                
            $this->load->view('header_view');
            
            if(isset($_POST['action']) && $_POST['action'] == "change_pwd")
                $data['message'] = $this->Users_model->changePassword($this->data['user']['user_mail'], $_POST['current_password'], $_POST['new_password']);
            
            $data['html'] = $this->load->view('settings_view', $data, true);
               
            $this->load->view('main_view', $data);
            $this->load->view('footer_view');
	}
}

/* End of file settings.php */
/* Location: ./application/controllers/settings.php */